package com.ruoyi.datam.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.base.datam.*;
import com.ruoyi.datam.mapper.*;
import com.ruoyi.datam.service.IStCrossBService;
import com.ruoyi.datam.util.NumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 渠道断面信息登记Service业务层处理
 *
 * @author hwd
 * @date 2023-02-16
 */
@Service
public class StCrossBServiceImpl implements IStCrossBService {
    @Autowired
    private StCrossBMapper stCrossBMapper;
    @Autowired
    private WiOrganBMapper wiOrganBMapper;
    @Autowired
    private WcChanBMapper wcChanBMapper;
    @Autowired
    private CmAddvBMapper cmAddvBMapper;
    @Autowired
    private WcSluiceBMapper wcSluiceBMapper;

    /**
     * 查询渠道断面信息登记
     *
     * @param crossCd 渠道断面信息登记主键
     * @return 渠道断面信息登记
     */
    @Override
    public StCrossB selectStCrossBByCrossCd(String crossCd) {
        return stCrossBMapper.selectStCrossBByCrossCd(crossCd);
    }

    /**
     * 查询渠道断面信息登记列表
     *
     * @param stCrossB 渠道断面信息登记
     * @return 渠道断面信息登记
     */
    @Override
    public List<StCrossB> selectStCrossBList(StCrossB stCrossB) {
        return stCrossBMapper.selectStCrossBList(stCrossB);
    }

    /**
     * 新增渠道断面信息登记
     *
     * @param stCrossB 渠道断面信息登记
     * @return 结果
     */
    @Override
    public int insertStCrossB(StCrossB stCrossB) {
       int count = stCrossBMapper.selectAllStCrossBList(new StCrossB()).size()+1;
        stCrossB.setCrossCd("CRO"+stCrossB.getOrgCd().substring(3,13)+ NumberUtil.geFourNumber(count,4));
        return stCrossBMapper.insertStCrossB(stCrossB);
    }

    /**
     * 修改渠道断面信息登记
     *
     * @param stCrossB 渠道断面信息登记
     * @return 结果
     */
    @Override
    public int updateStCrossB(StCrossB stCrossB) {
        return stCrossBMapper.updateStCrossB(stCrossB);
    }

    /**
     * 批量删除渠道断面信息登记
     *
     * @param crossCds 需要删除的渠道断面信息登记主键
     * @return 结果
     */
    @Override
    public int deleteStCrossBByCrossCds(String[] crossCds) {
        return stCrossBMapper.deleteStCrossBByCrossCds(crossCds);
    }

    /**
     * 删除渠道断面信息登记信息
     *
     * @param crossCd 渠道断面信息登记主键
     * @return 结果
     */
    @Override
    public int deleteStCrossBByCrossCd(String crossCd) {
        return stCrossBMapper.deleteStCrossBByCrossCd(crossCd);
    }
}
